//
//  RadioTableViewCell.m
//  OurRelax
//
//  Created by 于宾尧 on 15/6/19.
//  Copyright (c) 2015年 于宾尧. All rights reserved.
//

#import "RadioTableViewCell.h"

@implementation RadioTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self subMyViews];
    }
    return self;
}


-(void)subMyViews
{
    self.detailLabel = [[UILabel alloc]initWithFrame:CGRectMake(130, 10, 170, 30)];
    
    [self.contentView addSubview:self.detailLabel];
    
    self.aboutLabel = [[UILabel alloc]initWithFrame:CGRectMake(130, 50, 170, 20)];
    self.aboutLabel.font = [UIFont systemFontOfSize:13];
    self.aboutLabel.textColor = [UIColor lightGrayColor];
    self.aboutLabel.numberOfLines = 0;
    
    [self.contentView addSubview:self.aboutLabel];
    
    self.radioImage = [[UIImageView alloc]initWithFrame:CGRectMake(5, 5, 120, 120)];
    self.radioImage.backgroundColor = [UIColor blackColor];
    self.radioImage.layer.masksToBounds = YES;
    self.radioImage.layer.cornerRadius = 10;
    [self.contentView addSubview:self.radioImage];
    
    
}

-(void)setRadioMdl:(RadioModels *)radioMdl
{
    if (_radioMdl != radioMdl) {
        [_radioMdl release];
        _radioMdl = [radioMdl retain];
    }
    NSString *str = radioMdl.albumCoverUrl290;
    NSURL *url = [NSURL URLWithString:str];
    [self.radioImage sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"musicWebCache.jpeg"]];
    
    self.detailLabel.text = radioMdl.title ;
    self.aboutLabel.text = radioMdl.intro;
    CGRect textFrame = self.aboutLabel.frame;
    textFrame.size.height =[self.aboutLabel.text boundingRectWithSize:CGSizeMake(textFrame.size.width, CGFLOAT_MAX)options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
                                                          attributes:[NSDictionary dictionaryWithObjectsAndKeys:self.aboutLabel.font,NSFontAttributeName, nil] context:nil].size.height;
    self.aboutLabel.frame = CGRectMake(150, 50, 170, textFrame.size.height);

    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
